package com.ncu.web.controller;

import com.ncu.web.dao.mapper.AdminMapper;
import com.ncu.web.dao.mapper.ContactsMapper;
import com.ncu.web.dao.mapper.MajorityMapper;
import com.ncu.web.dao.mapper.UserMapper;
import com.ncu.web.entry.Majority;
import com.ncu.web.entry.Student;
import com.ncu.web.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:大润发杀鱼匠
 * @Date:2024/5/31 15:03 web
 */


@RestController
public class AdminController {

    @Autowired
    private AdminService adminService;
    @Autowired
    private AdminMapper adminMapper;
    @Autowired
    private MajorityMapper majorityMapper;
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private ContactsMapper contactsMapper;


    /**
     * 根据id删除专业
     * @param majority
     * @return
     */
    @GetMapping("/majority/delete")
    public String deleteMajority(Majority majority){
        String result=adminService.deleteMajority(majority);
        return result;
    }

    /**
     * 新增专业
     * @param majority
     * @return
     */
    @PostMapping("/majority/add")
    public String addMajority(Majority majority){
        String result=adminService.addMajority(majority);
        return result;
    }

    /**
     * 查询所有学生
     * @return
     */

    @GetMapping("/admin/get/all")
    public String getAllStu(Majority majority){
        String result=adminService.getAllStu();
        return result;
    }

    /**
     * 查询未通过授权的学生
     * @return
     */
    @GetMapping("/admin/failed")
    public String getFailedStu(){
        String result=adminService.getFailedStu();
        return result;
    }

    /**
     * 管理员为用户授权
     * @param student
     * @return
     */
    @GetMapping("/admin/authorization")
    public String openAuthority(Student student){
        String result=adminService.openAuthority(student.getId());
        return result;
    }

    /**
     * 禁用用户权限
     * @param student
     * @return
     */
    @GetMapping("/admin/forbidden")
    public String forbiddenAuthority(Student student){
        String result=adminService.forbiddenAuthority(student.getId());
        return result;
    }

    /**
     * 根据id删除未授权的学生
     * @param student
     * @return
     */
    @GetMapping("/admin/delete")
    public String deleteStudent(Student student){
        String result=adminService.deleteStudent(student.getId());
        return result;
    }

}
